﻿@using eCollabro.Client.Models.Content;
@using eCollabro.Client.Models.Core;
@using eCollabro.Web.Base;
@using eCollabro.Common;
@model ContentPageModel
@if (!Request.IsAjaxRequest())
{
    @Scripts.Render("~/bundles/contentpage")
}
@{
    List<PermissionEnum> userPermissions = (List<PermissionEnum>)ViewBag.UserPermissions;
    bool canEdit = userPermissions.Contains(PermissionEnum.EditContent);
    bool canDelete = userPermissions.Contains(PermissionEnum.DeleteContent);
    bool canAdd = userPermissions.Contains(PermissionEnum.AddContent);

    List<PageButton> pageButtons = new List<PageButton>();
    pageButtons.Add(new PageButton { Id = "btnPages", ButtonText = "Pages", CssClass = "btn btn-success", Icon = "th-list", Method = "openContentPages(" + Model.ContentPageCategoryId + ")" });
    if ((canEdit && !Model.ContentPageId.Equals(0)) || (canAdd && Model.ContentPageId.Equals(0)))
    {
        pageButtons.Add(new PageButton { Id = "btnSave", ButtonText = "Save", CssClass = "btn btn-primary", Icon = "floppy-disk", Method = "saveContentPage()" });
    }
}
<script type="text/javascript">
    $(document).ready(function () {
        $ContentPageContentEditor = $("#ContentPageContent").cleditor()[0];
        $ContentPageContentEditor.focus();
    });
</script>
<div id="divContentPage" ng-controller="contentPageController" ng-init="loadContentPage(@Model.ContentPageId,@Model.ContentPageCategoryId)">
    @Html.Partial("_PageHeader", new PageHeaderModel { ViewId = "ContentPage", PageTitle = "Content Page - Add/Edit", ValidateForm = true, PageButtons=pageButtons })
    @using (Html.BeginForm("ContentPage", "ContentPage", FormMethod.Post, new { role = "form", id = "frmContentPage", @class = "form-horizontal" }))
    {

        @Html.AntiForgeryToken()
        <div class="form-group">
            @Html.LabelFor(m => m.ContentPageTitle, new { @class = "col-md-2 control-label" })
            <div class="col-md-5">
                @Html.TextBoxFor(m => m.ContentPageTitle, new { ng_model = "contentPage.ContentPageTitle", @class = "form-control", maxlength = "50" })
                @Html.ValidationMessageFor(m => m.ContentPageTitle)
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(m => m.ContentPageDescription, new { @class = "col-md-2 control-label" })
            <div class="col-md-5">
                @Html.TextAreaFor(m => m.ContentPageDescription, new { ng_model = "contentPage.ContentPageDescription", @class = "form-control", maxlength = "255" })
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(m => m.ContentPageContent, new { @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @Html.TextAreaFor(m => m.ContentPageContent, new { ng_model = "contentPage.ContentPageContent", style = "width: 724px; height: 197px;" })
                @Html.ValidationMessageFor(m => m.ContentPageContent)
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(m => m.ContentPageCategoryId, new { @class = "col-md-2 control-label" })
            <div class="col-md-5">
                <select data-ng-model="selectedContentPageCategory" ng-options="contentPageCategory.ContentPageCategoryName for contentPageCategory in contentPageCategories" class="form-control" ng-change="updateContentPageCategory()">
                    <option value="">- Select -</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-2"></div>
            <div class="col-md-10">
                <div class="checkbox">
                    @Html.CheckBoxFor(m => m.IsActive, new { ng_model = "contentPage.IsActive" })
                    @Html.LabelFor(m => m.IsActive)
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-2"></div>
            <div class="col-md-10">
                <div class="checkbox">
                    @Html.CheckBoxFor(m => m.SetToHomePage, new { ng_model = "contentPage.SetToHomePage" })
                    @Html.LabelFor(m => m.SetToHomePage)
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-2"></div>
            <div class="col-md-10">
                <div class="checkbox">
                    @Html.CheckBoxFor(m => m.AddToNavigation, new { ng_model = "contentPage.AddToNavigation" })
                    @Html.LabelFor(m => m.AddToNavigation)
                </div>
            </div>
        </div>
        <div class="form-group" ng-show="contentPage.AddToNavigation">
            @Html.LabelFor(m => m.NavigationParentId, new { @class = "col-md-2 control-label" })
            <div class="col-md-5">
                <select data-ng-model="selectedParentNavigation" ng-options="parentNavigation.NavigationText for parentNavigation in parentNavigations" class="form-control" ng-change="updateParentNavigation()">
                    <option value="">Root Menu </option>
                </select>

            </div>
        </div>
        <div class="form-group" ng-show="contentPage.AddToNavigation">
            @Html.LabelFor(m => m.MenuTitle, new { @class = "col-md-2 control-label" })
            <div class="col-md-5">
                @Html.TextBoxFor(m => m.MenuTitle, new { ng_model = "contentPage.MenuTitle", @class = "form-control", maxlength = "50" })
                @Html.ValidationMessageFor(m => m.MenuTitle)
            </div>
        </div>
        <div class="col-md-1"></div>
        <div class="col-md-11">
            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">Content Setting</div>
                <div class="panel-body">
                    <div class="form-group" style="padding-left:5px">
                        <label class="checkbox-inline">
                            @Html.CheckBoxFor(m => m.IsAnomynousAccess, new { ng_model = "contentPage.IsAnomynousAccess" }) @Html.LabelFor(m => m.IsAnomynousAccess)
                        </label>
                        <label class="checkbox-inline">
                            @Html.CheckBoxFor(m => m.IsCommentsAllowed, new { ng_model = "contentPage.IsCommentsAllowed" }) @Html.LabelFor(m => m.IsCommentsAllowed)
                        </label>
                        <label class="checkbox-inline">
                            @Html.CheckBoxFor(m => m.IsLikeAllowed, new { ng_model = "contentPage.IsLikeAllowed" }) @Html.LabelFor(m => m.IsLikeAllowed)
                        </label>
                        <label class="checkbox-inline">
                            @Html.CheckBoxFor(m => m.IsRatingAllowed, new { ng_model = "contentPage.IsRatingAllowed" }) @Html.LabelFor(m => m.IsRatingAllowed)
                        </label>
                        <label class="checkbox-inline">
                            @Html.CheckBoxFor(m => m.IsVotingAllowed, new { ng_model = "contentPage.IsVotingAllowed" }) @Html.LabelFor(m => m.IsVotingAllowed)
                        </label>
                    </div>
                </div>
            </div>
        </div>
    <div class="col-md-12">
        @Html.Partial("_PageFooter", new PageFooterModel
                {
                    PageButtons = pageButtons
                })
    </div>

    }
</div>
